<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="backstage/layout">
<head>
    <title>管理后台</title>
</head>

<body>
<div id="content" layout:fragment="content">
<script type="text/javascript" src="../../admin/js/bootstrap-paginator.js"></script>
<script type="text/javascript" src="../../admin/ace/js/fuelux/fuelux.spinner.min.js"></script>
<script type="text/javascript" src="../../admin/ace/js/ace-elements.min.js"></script>
<script type="text/javascript" src="../../admin/ace/js/jquery.gritter.min.js"></script>
    <script type="text/javascript">
    	$(function(){
    		$('#id-input-file-1').ace_file_input({
                no_file: '没有文件 ...',
                btn_choose: 'Choose',
                btn_change: 'Change',
                droppable: false,
                onchange: null,
                thumbnail: false//| true | large
            });
//     		var myhtml = "<a class='btn'>上传</a>";
    		$("td").each(function(i,val){
    			 if($(val).find("img").attr('src') == ''){
    				$(val).not('.team_name').html("<a>上传</a>");
    				//data-toggle="modal" data-target="#myModal"
    				/* $(val).find("a").attr('data-toggle','modal');
    				$(val).find("a").attr('data-target','#myModal'); */
    				$(val).find("a").addClass('btn btn-info btn-small upload');
    			} 
    		});
    		$(".upload").click(function(e){
    			e.preventDefault();
    			//对应的时段类型
    			$('#url_type').val($(this).parent().attr('id'));
    			$('#id').val($(this).parent().siblings('.team_name').attr('id'));
    			$('#myModal').modal('show');
    		});
    		$(".re_upload").click(function(e){
    			e.preventDefault();
    			$('#url_type').val($(this).parent().parent().attr('id'));
    			$('#id').val($(this).parent().parent().siblings('.team_name').attr('id'));
    			$('#myModal').modal('show');
    		});
    		$('.del').click(function(e){
    			var url_type = $(this).parent().parent().attr('id')
    			if(confirm("确定删除吗?")){
                	$.post("/shootSpot/deleteById.json",
                			{id : e.currentTarget.id,
                			 url_type : url_type
                			},
                			function(data){
                				if(data.suc)
                                {
                                   // $(".close").click();
                                    alert("删除成功！");
                				 location.reload();
                                }else{
                                   alert("删除有误！");
                                }
                			},"JSON");
                }
    		});
    		$("#updateShootSpot").validate( {
                checkStart : true,
                errorElement: 'span',
                errorClass: 'help-inline',
                focusInvalid: false,
                /* rules : {
                    name : {
                        required: true
                    }
                },
                messages : {
                    name : {
                        required : "必须填写"
                    }
                }, */
                submitHandler : function(form) {

                    $("#updateShootSpot").ajaxSubmit(function(data){
                        if(data =="true"){
                            alert("修改成功了！");
                            $(".close").click();
                            location.reload();
                            //window.location.href = "/shootSpot/list.htm";
                        }else{
                        	alert("修改失败了！");
                        }
                    });
                },
                highlight: function (e) {
                    $(e).closest('.control-group').removeClass('info').addClass('error');
                }
            });
    	});
    </script>
    <div class="box-content">
        <div class="row-fluid sortable">
            <div class="box span12">
                <h3 class="row-fluid header smaller lighter blue">
                   <span class="label label-large label-pink arrowed-right">投篮点分布</span>
                </h3>
                <h4 class="row-fluid header lighter blue">
                	<span style="font-size: 1.5em;" class=" arrowed-right" th:text="${preliminaryContest.seasonName}"></span>
                </h4>   
                
                <form action="" method="post" id="searchForm">
                 </form>
                 
                 <div class="box-content">
                    <table class="table table-striped table-bordered bootstrap-datatable datatable">
                       <thead>
                       	<tr >
                            <th style="text-align: center;"></th>
                            <th style="text-align: center;">全场</th>
                            <th style="text-align: center;">第一节</th>
                            <th style="text-align: center;">第二节</th>
                            <th style="text-align: center;">第三节</th>
                            <th style="text-align: center;">第四节</th>
                            <th style="text-align: center;">加时一</th>
                            <th style="text-align: center;">加时二</th>
                            <th style="text-align: center;">加时三</th>
                            <th style="text-align: center;">加时四</th>
                        </tr>
                       </thead>
                       <tbody>
                       	<tr th:each="shootSpot:${page.result}">
                       		<td class="team_name" style="text-align: center; font-size: 25px;" th:id="${shootSpot.id}" th:text="${shootSpot.teamName}"></td>
                       		<td style="text-align: center;" id="0">
	                       		<img alt="全场"  th:src="${shootSpot.fullTimeUrl}" />
	                       		<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="1">
								<img alt="第一节"  th:src="${shootSpot.firstTimeUrl}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="2">
								<img alt="第二节"  th:src="${shootSpot.secondTimeUrl}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="3">
                       			<img alt="第三节"  th:src="${shootSpot.thirdTimeUrl}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="4">
                       			<img alt="第四节"  th:src="${shootSpot.fourthTimeUrl}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="5">
                       			<img alt="加时一"  th:src="${shootSpot.extraTimrUrl}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="6">
                       			<img alt="加时二"  th:src="${shootSpot.extraTimrUrl2}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="7">
                       			<img alt="加时三"  th:src="${shootSpot.extraTimrUrl3}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<td style="text-align: center;" id="8">
                       			<img alt="加时四"  th:src="${shootSpot.extraTimrUrl4}" />
                       			<div><a style="padding: 10px;" href="#" class="re_upload">重新上传</a><a th:id="${shootSpot.id}" class="del" href="#">删除</a></div>
                       		</td>
                       		<!-- <td style="text-align: center;">
                       			<a href="#" class="btn btn-small btn-success btn-setting" data-toggle="modal" data-target="#myModal">上传</a>
                       		</td> -->
                       	</tr>
                       </tbody>
                    </table> 
                    
                     <div style="margin-bottom: 0px; margin-left: auto;margin-right: auto">
                        <div id="example" style="margin-bottom:0px"></div>
                     </div>
                </div>
           	</div>
        </div>
     </div>
      <div id="myModal" class="modal hide fade in">
        <div class="modal-header">
            <button class="close" data-dismiss="modal" type="button">×</button>
            <h3>上传图片</h3>
        </div>
        <form class="form-horizontal" style="margin: 0" enctype="multipart/form-data" action="/shootSpot/addOrUpdate.htm" method="post" id="updateShootSpot">
        	
            <fieldset>
                <div class="modal-body">
                      <div class="controls">
                         <input type="hidden" id="url_type" name="url_type"/>
                         <input type="hidden" id="id" name="id"/>
                      </div>
                    <div class="control-group">
                      <label class="control-label">上传图片：</label>
                      <div class="controls">
                         <input id="id-input-file-1"  type="file"  name="file" />
                      </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="submit" class="btn btn-primary" value="保存" />
                    <a href="#" class="btn btn-small" data-dismiss="modal">取消</a>
                </div>
            </fieldset>
        </form>
    </div>
</div>
</body>
</html>
